package com.feng.rabbitmq.two;

import com.feng.rabbitmq.utiils.RabbitMQUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

/**
 * 消费者
 */
public class Worker01 {
    public static final String QUEUN_NAME = "hello";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();
        DeliverCallback deliverCallback = (consumerTag,message) ->{
            System.out.println("接收到的消息："+new String(message.getBody()));
        };
        CancelCallback cancelCallback = consumerTag ->{
            System.out.println("回调的："+consumerTag);
        };
        //使用idea工具测试: 需要配置run里面的——Allow parallel run
        System.out.println("c2等待接收消息...");
        channel.basicConsume(QUEUN_NAME,true,deliverCallback,cancelCallback);
    }
}
